<?php
/**
 * Created by PhpStorm.
 * User: Vladimir
 * Date: 31.05.14
 * Time: 12:47
 */
$get=$_GET;
$currentLanguage = Yii::app()->language;
?>

<div id="content" class="clearfix">
<div class="top-wrapper">
    <div class="top">
        <div class="top-inner">
            <div id="rev-slider-widget-2" class="widget widget_revslider"></div>        </div><!-- /.top-inner -->
    </div><!-- /.top -->
</div><!-- /.top-wrapper -->

<div class="container">
<div class="row">



<div id="main" class="span9">
<h1 class="page-header"><?php echo Yii::t('main', 'Properties') ?></h1>


<script type="text/javascript">
    jQuery(document).ready(function ($) {
        $('select[name=filter_sort_by]').change(function () {
            $('form.form-sort').submit();
        });

        $('select[name=filter_order]').change(function () {
            $('form.form-sort').submit();
        });
    });
</script>

<div class="properties-rows">
    <div class="filter">
        <form action="/property/filter/" method="get" class="form-sort form-horizontal">
            <input type="hidden" name="filter_location" value="">
            <input type="hidden" name="filter_type" value="">
            <input type="hidden" name="filter_bedrooms" value="">
            <input type="hidden" name="filter_bathrooms" value="">
            <input type="hidden" name="filter_price_from" value="">
            <input type="hidden" name="filter_price_to" value="">
            <input type="hidden" name="filter_property_id" value="">

            <div class="control-group">
                <label class="control-label" for="inputSortBy">
                    <?php echo Yii::t('main', 'Sort by') ?>
                </label>

                <div class="controls">
                    <select name="filter_sort_by" id="inputSortBy">
                        <option <?php echo (isset($get['filter_sort_by'])&&$get['filter_sort_by']=='name_'.$currentLanguage)?'selected="selected"':'' ?> value="name_<?php echo $currentLanguage; ?>" >Name</option>
                        <option <?php echo (isset($get['filter_sort_by'])&&$get['filter_sort_by']=='create_date')?'selected="selected"':'' ?> value="create_date" >Date</option>
                        <option <?php echo (isset($get['filter_sort_by'])&&$get['filter_sort_by']=='price')?'selected="selected"':'' ?>  value="price" >Price</option>
                        <option <?php echo (isset($get['filter_sort_by'])&&$get['filter_sort_by']=='beds')?'selected="selected"':'' ?> value="beds" >Bedrooms</option>
                        <option <?php echo (isset($get['filter_sort_by'])&&$get['filter_sort_by']=='bath')?'selected="selected"':'' ?> value="bath" >Bathrooms</option>
                        <option <?php echo (isset($get['filter_sort_by'])&&$get['filter_sort_by']=='area')?'selected="selected"':'' ?> value="area" >Area</option>
                        <option <?php echo (isset($get['filter_sort_by'])&&$get['filter_sort_by']=='location')?'selected="selected"':'' ?> value="location" >Location</option>
                        <option <?php echo (isset($get['filter_sort_by'])&&$get['filter_sort_by']=='type')?'selected="selected"':'' ?> value="type" >Type</option>
                        <option <?php echo (isset($get['filter_sort_by'])&&$get['filter_sort_by']=='rate')?'selected="selected"':'' ?> value="rate" >Rate</option>
                    </select>
                </div>
                <!-- /.controls -->
            </div>
            <!-- /.control-group -->

            <div class="control-group">
                <label class="control-label" for="inputOrder">
                    <?php echo Yii::t('main', 'Order') ?>
                </label>

                <div class="controls">
                    <select id="inputOrder" name="filter_order">
                        <option <?php echo (isset($get['filter_order'])&&$get['filter_order']=='DESC')?'selected="selected"':'' ?> value="DESC" >DESC</option>
                        <option <?php echo (isset($get['filter_order'])&&$get['filter_order']=='ASC')?'selected="selected"':'' ?> value="ASC" >ASC</option>
                    </select>
                </div>
                <!-- /.controls -->
            </div>
            <!-- /.control-group -->
        </form>
    </div>
    <!-- /.filter -->
</div><!-- /.properties-rows -->

<div class="properties-rows">
<div class="row">
<?php
foreach ($models as $model){
    echo'
    <div class="property span9">
    <div class="row">
        <div class="image span3">
            <div class="content">
                <a href="/site/property/id/'.$model['id'].'"></a>
                <img src="/uploads/'.$model['id'].'/thumb_270/'.$model['image'].'" alt="27523 Pacific Coast">
            </div>
            <!-- /.content -->
        </div>
        <!-- /.image -->

        <div class="body span6">
            <div class="title-price row">
                <div class="title span4">
                    <h2><a href="/site/property/id/'.$model['id'].'">'.$model['name_'.$this->currentLanguage].'</a></h2>
                </div>
                <!-- /.title -->

                <div class="price">'.$model['price'].' €</div>
                <!-- /.price -->
            </div>
            <!-- /.title -->

            <div class="location">'.$model['location'].'</div>
            <!-- /.location -->

            <div class="body">
                '.mb_substr($model['about_'.$this->currentLanguage],0,400).'
            </div>
            <!-- /.body -->

            <div class="info clearfix">
                <div class="area">
                    <span class="key">Area:</span><!-- /.key -->
                    <span class="value">'.$model['area'].'m<sup>2</sup></span><!-- /.value -->
                </div><!-- /.area -->

                <div class="bedrooms" title="Bedrooms">
                    <div class="content">'.$model['beds'].'</div>
                </div><!-- /.bedrooms -->

                <div class="bathrooms" title="Bathrooms">
                    <div class="content">'.$model['bath'].'</div>
                </div><!-- /.bathrooms -->
            </div>
            <!-- /.info -->
        </div>
        <!-- /.body -->
    </div>
    <!-- /.row -->
    </div><!-- /.property -->
    ';
}
?>

</div><!-- /.row -->
</div><!-- /.properties-grid -->




<div class="pagination pagination-centered">
<!--    <ul class="unstyled">-->
<!--        <li class='active'><a href='#'>1</a></li>-->
<!--        <li><a href='http://wp.realia.byaviators.com/properties/page/2/?filter_location&#038;filter_type&#038;filter_bedrooms&#038;filter_bathrooms&#038;filter_price_from&#038;filter_price_to&#038;filter_property_id' class='inactive' >2</a></li>-->
<!--        <li><a href='http://wp.realia.byaviators.com/properties/page/3/?filter_location&#038;filter_type&#038;filter_bedrooms&#038;filter_bathrooms&#038;filter_price_from&#038;filter_price_to&#038;filter_property_id' class='inactive' >3</a></li>-->
<!--        <li><a href='http://wp.realia.byaviators.com/properties/page/4/?filter_location&#038;filter_type&#038;filter_bedrooms&#038;filter_bathrooms&#038;filter_price_from&#038;filter_price_to&#038;filter_property_id' class='inactive' >4</a></li>-->
<!--    </ul>-->
    <?php $this->widget('CLinkPager', array(
        'pages' => $pages,
        'header' => '',
//        'prevPageLabel' => '&laquo; <<',
//        'nextPageLabel' => '>> &raquo;',
        'prevPageLabel' => '<<',
        'nextPageLabel' => '>>',
        'htmlOptions' => array(
            'style' => 'display:inline-block'
        ),
    )) ?>
</div>

</div><!-- /#main -->

<div class="sidebar span3">

<h2><?php echo Yii::t('main', 'Filter') ?></h2>

<div class="property-filter widget">
    <div class="content">
        <form method="get" action="/property/filter/">
            <div class="location control-group">
                <label class="control-label" for="inputLocation-">
                    <?php echo Yii::t('main', 'Location') ?>
                </label>

                <div class="controls">
                    <select name="filter_location" id="inputLocation-">
                        <option value>-</option>
                        <option value="6">Palo Alto, SA</option>
                        <option value="7">Silicon Valley, SA</option>
                    </select>
                </div>
                <!-- /.controls -->
            </div><!-- /.control-group -->

            <div class="type control-group">
                <label class="control-label" for="inputType-">
                    <?php echo Yii::t('main', 'Type') ?>
                </label>

                <div class="controls">
                    <select name="filter_type" id="inputType-">
                        <option value>-</option>
                        <option value="51">Apartment</option>
                        <option value="2">Building Area</option>
                        <option value="3">Condo</option>
                        <option value="4">Cottage</option>
                        <option value="5">Family House</option>
                        <option value="49">Single Home</option>
                        <option value="50">Villa</option>
                    </select>
                </div>
                <!-- /.controls -->
            </div>
            <!-- /.control-group -->

            <div class="beds control-group">
                <label class="control-label" for="inputBeds-">
                    <?php echo Yii::t('main', 'Beds') ?>
                </label>

                <div class="controls">
                    <select name="filter_bedrooms" id="inputBeds-">
                        <option value>-</option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                        <option value="6">6</option>
                        <option value="7">7</option>
                        <option value="8">8</option>
                        <option value="9">9</option>
                        <option value="10">10</option>
                    </select>
                </div>
                <!-- /.controls -->
            </div>
            <!-- /.control-group -->

            <div class="baths control-group">
                <label class="control-label" for="inputBaths-">
                    <?php echo Yii::t('main', 'Baths') ?>
                </label>

                <div class="controls">
                    <select name="filter_bathrooms" id="inputBaths-">
                        <option value>-</option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                        <option value="6">6</option>
                        <option value="7">7</option>
                        <option value="8">8</option>
                        <option value="9">9</option>
                        <option value="10">10</option>
                    </select>
                </div>
                <!-- /.controls -->
            </div>
            <!-- /.control-group -->


            <div class="price-from control-group">
                <label class="control-label" for="inputPriceFrom-">
                    <?php echo Yii::t('main', 'Price From') ?>
                </label>

                <div class="controls">
                    <select name="filter_price_from" id="inputPriceFrom-">
                        <option value>-</option>
                        <option value="1000">1000 €</option>
                        <option value="20000">20000 €</option>
                        <option value="50000">50000 €</option>
                        <option value="100000">100000 €</option>
                    </select>
                </div>
                <!-- /.controls -->
            </div>
            <!-- /.control-group -->

            <div class="price-to control-group">
                <label class="control-label" for="inputPriceTo-">
                    <?php echo Yii::t('main', 'Price To') ?>
                </label>

                <div class="controls">
                    <select name="filter_price_to" id="inputPriceTo-">
                        <option value>-</option>
                        <option value="1000">1000 €</option>
                        <option value="20000">20000 €</option>
                        <option value="50000">50000 €</option>
                        <option value="100000">100000 €</option>
                    </select>
                </div>
                <!-- /.controls -->
            </div>
            <!-- /.control-group -->



            <div class="control-group">
                <label class="control-label" for="inputPropertyId-">
                    <?php echo Yii::t('main', 'Property ID') ?>
                </label>

                <div class="controls">
                    <input type="text" value name="filter_property_id" id="inputPropertyId-">
                </div><!-- /.controls -->
            </div><!-- /.control-group -->

            <div class="form-actions">
                <button class="btn btn-primary btn-large"><?php echo Yii::t('main', 'Filter now!') ?></button>
            </div>
            <!-- /.form-actions -->
        </form>
    </div>
    <!-- /.content -->
</div><!-- /.property-filter -->
<div id="agents_widget-2" class="widget our-agents">

    <h2><?php echo Yii::t('main', 'Agents') ?></h2>

    <div class="content">
        <div class="agent clearfix">
            <div class="image">
                <a href="http://wp.realia.byaviators.com/agents/john-connor/">
                    <img width="140" height="141" src="http://wp.realia.byaviators.com/wp-content/uploads/2013/05/john-small.png" class="attachment-post-thumbnail wp-post-image" alt="john-small" />
                </a>
            </div>
            <!-- /.image -->

            <div class="name">
                <a href="http://wp.realia.byaviators.com/agents/john-connor/">John Connor</a>
            </div>
            <!-- /.name -->
            <div class="phone">666-999-888</div>
            <!-- /.phone -->
            <div class="email"><a href="mailto:connor@example.com">connor@example.com</a>
            </div>
            <!-- /.email -->
        </div><!-- /.agent -->
        <div class="agent clearfix">
            <div class="image">
                <a href="http://wp.realia.byaviators.com/agents/martin-crane/">
                    <img width="140" height="141" src="http://wp.realia.byaviators.com/wp-content/uploads/2013/05/emma-small.png" class="attachment-post-thumbnail wp-post-image" alt="emma-small" />
                </a>
            </div>
            <!-- /.image -->

            <div class="name">
                <a href="http://wp.realia.byaviators.com/agents/martin-crane/">Sarah Connor</a>
            </div>
            <!-- /.name -->
            <div class="phone">222-333-444</div>
            <!-- /.phone -->
            <div class="email"><a href="mailto:martin@example.com">martin@example.com</a>
            </div>
            <!-- /.email -->
        </div><!-- /.agent -->
        <div class="agent clearfix">
            <div class="image">
                <a href="http://wp.realia.byaviators.com/agents/john-doe/">
                    <img width="140" height="141" src="http://wp.realia.byaviators.com/wp-content/uploads/2013/05/john-small.png" class="attachment-post-thumbnail wp-post-image" alt="john-small" />
                </a>
            </div>
            <!-- /.image -->

            <div class="name">
                <a href="http://wp.realia.byaviators.com/agents/john-doe/">John Doe</a>
            </div>
            <!-- /.name -->
            <div class="phone">000-222-333</div>
            <!-- /.phone -->
            <div class="email"><a href="mailto:john@example.com">john@example.com</a>
            </div>
            <!-- /.email -->
        </div><!-- /.agent -->
    </div><!-- /.content -->

</div>
<div id="featuredproperties_widget-4" class="widget properties">

    <h2><?php echo Yii::t('main', 'Featured') ?></h2>

    <div class="content">
        <?php
        $rectntProperty=(Controller::recentPropertyes());
        foreach ($rectntProperty as $property){
            echo'
                            <div class="property">
                                <div class="image">
                                    <a href="/site/property/id/'.$property['id'].'"></a>
                                    <img src="/uploads/'.$property['id'].'/thumb_240/'.$property['image'].'" alt="3412 Cloudcroft Dr">
                                </div>
                                <div class="wrapper">
                                    <div class="title">
                                        <h3><a href="/site/property/id/'.$property['id'].'">
                                                '.$property['name_'.$this->currentLanguage].'
                                            </a></h3>
                                    </div>
                                    <div class="location">'.$property['location'].'</div>
                                    <div class="price">
                                        '.$property['price'].' €                                             </div>
                                </div>
                            </div>
                                ';
        }
        ?>
        </div>            </div><!-- /.content -->

</div>

</div><!-- /#sidebar -->
</div><!-- /.row -->

<div class="content-bottom-wrapper">
    <div class="content-bottom">
        <div class="content-bottom-inner">
        </div><!-- /.content-bottom-inner -->
    </div><!-- /.content-bottom -->
</div><!-- /.content-bottom-wrapper -->
</div><!-- /.container -->

</div><!-- /#content -->
</div><!-- /#wrapper-inner -->